package com.example.conference.service;

import com.example.conference.domain.CourseTeacher;
import com.example.conference.domain.dto.PageParam;
import com.example.conference.domain.vo.CourseTeacherVo;
import com.example.conference.domain.vo.UserVo;
import com.example.conference.mapper.CourseTeacherMapper;
import com.example.conference.utils.Result;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class CourseTeacherServiceImpl {
    @Autowired
    CourseTeacherMapper courseTeacherMapper;

    public Result addCourseTeacher(CourseTeacher courseTeacher) {
        if (courseTeacherMapper.add(courseTeacher) != null) {
            return Result.success();
        }
        return Result.error("添加错误");
    }



    public Result queryCourseByTeacher(PageParam page, Integer tId) {
        PageHelper.startPage(page.getPageNum(), page.getPageSize());
        Page<CourseTeacherVo> courseTeacher = courseTeacherMapper.queryByTeacher(tId);
        return Result.success().data("items",courseTeacher.doSelectPageInfo(()-> courseTeacherMapper.queryByTeacher(tId)));
    }
    public Result deleteCourseTeacher(Integer ctId) {
        if (courseTeacherMapper.delete(ctId) != null) {
            return Result.success();
        }
        return Result.error("删除错误");
    }

}
